﻿using Hotel_Project.Bean;
using Hotel_Project.Tools.MySqlData_Helps;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Hotel_Project.BIZ
{
    internal class AddToolStrip
    {
        public AddToolStrip() { }
        public async void addToolStrip(ToolStrip t)
        {
            t.Items.Clear();
            t.ImageScalingSize = new Size(100,50);
            //动态抓取数据库中的数据
            MySqlDataTable mySqlDataTable = new MySqlDataTable();
            DataTable data = await mySqlDataTable.GetDataTable(MySqlString.MYSQL_CONNAND, MySqlString.MYSQL_SELECT_toolbar);
            List<ToolStripDomain> list = MySqlGetList.GetDataList<ToolStripDomain>(data);
            int Count = 0;
            foreach (ToolStripDomain domain in list)
            {
                if (Count==3)
                {
                    ToolStripSeparator ts = new ToolStripSeparator();
                    ts.Width = 20;
                    t.Items.Add(ts);
                }
                if (Count == 9)
                {
                    ToolStripSeparator ts = new ToolStripSeparator();
                    ts.Width = 20;
                    t.Items.Add(ts);
                }
                ToolStripButton too = new ToolStripButton(domain.text,Image.FromFile(domain.imgpath));
                too.TextImageRelation = TextImageRelation.ImageAboveText;
                too.Font = new Font("微软雅黑", 10,FontStyle.Bold);
                too.Padding = new Padding(8);
                t.Items.Add(too);
                Count++;
            }
        }
    }
}
